package top.hjcwzx.wrench.design.framework.service.tree.node;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.hjcwzx.wrench.design.framework.tree.StrategyHandler;
import top.hjcwzx.wrench.design.framework.model.tree.TreeReq;
import top.hjcwzx.wrench.design.framework.model.tree.TreeRes;
import top.hjcwzx.wrench.design.framework.service.tree.AbstractTestSupport;
import top.hjcwzx.wrench.design.framework.service.tree.factory.DefaultTreeTestFactory;


@Slf4j
@Service
@RequiredArgsConstructor
public class TestNode extends AbstractTestSupport<TreeReq, DefaultTreeTestFactory.DynamicContext, TreeRes> {

    private final EndNode endNode;

    @Override
    public TreeRes apply(TreeReq requestParameter, DefaultTreeTestFactory.DynamicContext dynamicContext) throws Exception {
        log.info("抽象规则决策树-业务节点执行逻辑");
        dynamicContext.setField("业务节点执行逻辑结果");
        return router(requestParameter, dynamicContext);
    }

    @Override
    public StrategyHandler<TreeReq, DefaultTreeTestFactory.DynamicContext, TreeRes> get(TreeReq requestParameter, DefaultTreeTestFactory.DynamicContext dynamicContext) throws Exception {
        log.info("抽象规则决策树-业务节点流转-下一节点-末尾节点:{}", endNode);
        return endNode;
    }
}
